/**
 *服饰的位图数据系列缓存 ，让位图数据相同的位图共享一个位图数据以减小内存消耗
 * author:noodles 
 */
package com.gamebase.role
{
	import flash.display.BitmapData;
	import flash.utils.Dictionary;

	public class DesignBMDCache
	{
		private static var _instance:DesignBMDCache;
		private var cacheDic:Dictionary;
		
		public function DesignBMDCache()
		{
			cacheDic = new Dictionary();
		}
		
		private static function get instance():DesignBMDCache
		{
			if(_instance == null)
				_instance = new DesignBMDCache();
			return _instance;
		}
		
		public static function getCache(cacheName:String):Vector.<Vector.<BitmapData>>
		{
			return instance.cacheDic[cacheName] as Vector.<Vector.<BitmapData>>;
		}
		
		//将服装位图数据系列加入缓存
		public static function addToCache(mcData:Vector.<Vector.<BitmapData>>, designName:String):void
		{
			if(instance.cacheDic[designName]==null)
				instance.cacheDic[designName] = mcData;
		}
		
		//将服装从缓存中销毁
		public static function removeCache(mcData:Vector.<Vector.<BitmapData>>, designName:String):void
		{
			if(instance.cacheDic[designName])
				delete instance.cacheDic[designName];
		}
		
		public static function hasNoCache(designName:String):Boolean
		{
			if(instance.cacheDic[designName]==null)
				return true;
			else
				return false;
		}
	}
}